<template>
  <basic-dialog
    title="查看修改日志"
    :visible="visible"
    :handleClose="handleCancel"
    :showFooter="false"
  >
    <SkusTable
      showPagination
      :tableHeight="440"
      :showSelectCol="false"
      :loading="TableInfo.loading"
      :columns="TableInfo.columns"
      :dataSource="TableInfo.list"
      :pagination="pagination"
      :pageSizes="pageSizes"
      :total="pagination.total"
      @pageChange="handlePageChange"
      @pageSizeSelect="handlePageSizeChange"
    />
  </basic-dialog>
</template>
<script>
import BasicDialog from '@/components/BasicDialog';
import SkusTable from '@/components/skusTable';
import skusPage from '@/mixins/commodity/skusPage';
import { TableInfo } from '@/utils/getUtils';
import { TABLE_COLUMNS } from './constants';
import { secondPhaseTaskDetailSearchService } from '@/api/public';
export default {
  mixins: [skusPage],
  components: {
    BasicDialog,
    SkusTable
  },
  props: {
    visible: {
      type: Boolean,
      required: true
    },
    curRow: {
      type: Object,
      default: () => ({})
    }
  },
  data () {
    return {
      TableInfo: new TableInfo({ columns: TABLE_COLUMNS }),
      pageSizes: [10, 100, 1000]
    }
  },
  watch: {
    visible (val) {
      val && this.getTableData()
    },
  },
  methods: {
    // 获取查询参数
    getSearchParams () {
      const data = {
        ..._.pick(this.curRow, ['categoryUuid', 'brandUuid', 'seriesUuid']),
        ...this.paginationParams
      }
      return data
    },
    // 设置表格列表集合
    async getTableData () {
      const data = this.getSearchParams()
      const res = await secondPhaseTaskDetailSearchService(data, this.TableInfo.setLoading)
      this.TableInfo.setList(res?.retData?.results ?? [])
      this.setTotalNum(res.retData.totalNum ?? 0)
    },
    handleCancel () {
      this.$emit('update:visible', false)
    }
  }
}
</script>
